template<class T>
T power(T a, ll b) {
  T res = 1;
  for (; b; b /= 2, a *= a) {
    if (b % 2) {
      res *= a;
    }
  }
  return res;
}
template <int P>
struct Mint {
  int x;
  Mint(int x = 0) : x(Vnorm(x)) {}
  Mint(ll x) : x(Vnorm(x % P)) {}

  // assume -P <= x < 2P
  int Vnorm(int x) {
    if (x < 0) {
      x += P;
    }
    if (x >= P) {
      x -= P;
    }
    return x;
  }
  int val() const {
    return x;
  }
  Mint operator-() const {
    return Mint(Vnorm(P - x));
  }
  Mint inv() const {
    assert(x != 0);
    return power(*this, P - 2);
  }
  Mint &operator*=(const Mint &rhs) {
    x = ll(x) * rhs.x % P;
    return *this;
  }
  Mint &operator+=(const Mint &rhs) {
    x = Vnorm(x + rhs.x);
    return *this;
  }
  Mint &operator-=(const Mint &rhs) {
    x = Vnorm(x - rhs.x);
    return *this;
  }
  Mint &operator/=(const Mint &rhs) {
    return *this *= rhs.inv();
  }
  friend Mint operator*(const Mint &lhs, const Mint &rhs) {
    Mint res = lhs;
    res *= rhs;
    return res;
  }
  friend Mint operator+(const Mint &lhs, const Mint &rhs) {
    Mint res = lhs;
    res += rhs;
    return res;
  }
  friend Mint operator-(const Mint &lhs, const Mint &rhs) {
    Mint res = lhs;
    res -= rhs;
    return res;
  }
  friend Mint operator/(const Mint &lhs, const Mint &rhs) {
    Mint res = lhs;
    res /= rhs;
    return res;
  }
  friend std::istream &operator>>(std::istream &is, Mint &a) {
    ll v;
    is >> v;
    a = Mint(v);
    return is;
  }
  friend std::ostream &operator<<(std::ostream &os, const Mint &a) {
    return os << a.val();
  }
};
using Z = Mint<998244353>;